#
# Makefile.cvs for the CVS tree only
#

CFLAGS       = -D__KERNEL__ -DMODULE  -Wall -Wstrict-prototypes -O2
CONFIG_FLAGS = -DCONFIG_VIDEO_RIVATV \
	       -DCONFIG_PROC_FS -DCONFIG_VIDEO_DEV \
               -DCONFIG_PCI \
	       -DEXPORT_SYMTAB
#KCFLAGS      = -DRIVATV_DISABLE_CONVERSION -DRIVATV_DISABLE_AGP
KERNEL       = /lib/modules/`uname -r`/build
#KERNEL      = /usr/src/`uname -r`
INCLUDES     = -I. -I$(KERNEL)/include -I$(KERNEL)/drivers/media/video
CC           = gcc
LD           = ld
LDFLAGS      = -m elf_i386

SOURCES      = saa7113h.c saa7111a.c saa7108e.c i2c-detect.c tw98.c vpx32xx.c
RIVATV_OBJS  = rivatv-driver.o v4l-riva.o i2c-riva.o procfs-riva.o rivatv-cards.o rivatv-convert.o dma-riva.o
TARGETS      = $(SOURCES:.c=.o) rivatv.o

all: $(TARGETS)

kall:
	make -C $(KERNEL) SUBDIRS=`pwd` EXTRA_CFLAGS="$(INCLUDES) $(KCFLAGS)" modules

modprobe:
	modprobe videodev
	modprobe i2c-core
	modprobe i2c-algo-bit

insmod:
	insmod rivatv.o
	insmod saa7113h.o

rmmod:
	-rmmod saa7113h
	-rmmod rivatv

clean:
	rm -f *~ *.o $(TARGETS) .*.o.cmd .*.o.flags *.ko *.mod.c .*.ko.cmd

patch:
	(cd ../../../../ && diff -urbB --unidirectional-new-file /usr/src/linux-2.4.17/ linux/ --exclude=".*" --exclude="CVS*" --exclude="Makefile.cvs" --exclude="*.o" | grep -v "Only in" > patch.diff)

rivatv.o: $(RIVATV_OBJS)
	$(LD) $(LDFLAGS) -r -o $@ $(RIVATV_OBJS)

%.o: %.c rivatv.h i2c-riva.h dma-riva.h rivatv-kcompat.h
	$(CC) $(CFLAGS) $(CONFIG_FLAGS) $(INCLUDES) -o $@ -c $<

.PHONY: all clean modprobe insmod rmmod patch

